# class Solution(object):
#     def peakIndexInMountainArray(self, arr):
#         """
#         :type arr: List[int]
#         :rtype: int
#         """
#         return arr.index(max(arr))
class Solution(object):
    def peakIndexInMountainArray(self, arr):
        """
        :type arr: List[int]
        :rtype: int
        """
        left = 1
        right = len(arr) - 2
        while True:
            mid = (left + right) // 2
            if arr[mid - 1] < arr[mid] and arr[mid] > arr[mid + 1]:
                return mid
            else:
                if arr[mid] < arr[mid - 1]:
                    right = mid - 1
                else:
                    left = mid + 1


data = Solution()
arr = [3, 4, 5, 1]
print(data.peakIndexInMountainArray(arr))
